#region License
// /* **************************************************************
// * Copyright (C) intex Consulting GmbH - All Rights Reserved    *
// *--------------------------------------------------------------*
// * Unauthorized copying of this file, via any medium is         *
// * strictly prohibited                                          *
// *--------------------------------------------------------------*
// * Proprietary and confidential                                 *
// *--------------------------------------------------------------*
// * Dissasembling/modifications strictly prohibited!             *
// ***************************************************************/
#endregion

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

namespace ComHlp.ContentClasses.VirtualControls.LView
{
    [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")]
    public class ItxListView : ICloneable
    {
        /// <summary> rowcount </summary>
        public int RowCount { get; set; }

        /// <summary> listview number </summary>
        public int ListViewNo { get; set; } = 1;

        /// <summary> field no of tbu from fordmef </summary>
        // ReSharper disable once UnusedAutoPropertyAccessor.Local
        private int ItxFieldNo { get; set; }

        /// <summary> zelement (last element) </summary>
        public ItxListViewColumn ZColumn { get; set; }

        /// <summary> listview elements</summary>
        public List<ItxListViewColumn> Columns { get; private set; } = new List<ItxListViewColumn>();

        public List<ItxListViewRowColor> RowColors { get; private set; } = new List<ItxListViewRowColor>();

        /// <summary> listview has got VMs </summary>
        public bool HasVmAssigned { get; set; }

        /// <summary> field length for VMs - necessary because we receive the header,vm,element or header,element,vm..
        /// so when we are building the header we do not know at this time if a vm is following </summary>
        public int VmFieldLength { get; set; }

        /// <summary> column no of the vm - if it is smaller/bigger than the listview column no, the whole listview receives
        /// a new position or a longer width </summary>
        public int VmColumnNo { get; set; }

        ///// <summary> if a vm contains an error, the row is set here </summary>
        //public int VmErroneousRow { get; set; } = -1;

        /// <summary> at least one column is allowing actions </summary>
        public bool AllowActions { get; set; }


        /// <summary> have we got a 2cond vm? </summary>
        public bool Has2CondVmAssigned { get; set; }

        /// <summary> field length for VMs - necessary because we receive the header,vm,element or header,element,vm..
        /// so when we are building the header we do not know at this time if a vm is following </summary>
        public int Vm2FieldLength { get; set; }

        /// <summary> if we have got a second vm, tell the base name here </summary>
        public string Vm2Name { get; set; }

        /// <summary> column no of the vm - if it is smaller/bigger than the listview column no, the whole listview receives
        /// a new position or a longer width </summary>
        public int Vm2ColumnNo { get; set; }

        ///// <summary> if a vm contains an error, the row is set here </summary>
        //public int Vm2ErroneousRow { get; set; } = -1;

        /// <summary> current screen no </summary>
        public int ScreenNo { get; set; } = -1;

        /// <summary> additional fields </summary>
        public bool HasAdditionalFields { get; set; }

        /// <summary> most last column on the right - if we include addition fields inside the listview </summary>
        public int MostLastColumn { get; set; } = -1;

        public ItxListView(int fieldNo)
        {
            ItxFieldNo = fieldNo;
        }

        object ICloneable.Clone() { return Clone(); }
        public ItxListView Clone()
        {
            ItxListView itxListView = MemberwiseClone() as ItxListView;
            if (itxListView == null)
                return null;

            List<ItxListViewColumn> clonedColumns = new List<ItxListViewColumn>(itxListView.Columns.Count);
            if (itxListView.Columns.Count > 0)
                clonedColumns.AddRange(itxListView.Columns.Select(column => column.Clone()));
            itxListView.Columns = clonedColumns;

            List<ItxListViewRowColor> clonedRowColors = new List<ItxListViewRowColor>(itxListView.RowColors.Count);
            if (itxListView.RowColors.Count > 0)
                clonedRowColors.AddRange(itxListView.RowColors.Select(rowColor => rowColor.Clone()));
            itxListView.RowColors = clonedRowColors;

            return itxListView;
        }
    }
}